/*
 * @Author: 詹真琦(legendryztachi@gmail.com)
 * @Date: 2022-01-19 11:26:14
 * @LastEditors: 詹真琦(legendryztachi@gmail.com)
 * @LastEditTime: 2022-04-28 15:10:04
 * @FilePath: \code\cwp-front\pc-collaboration\src\handles\handle-list\summary\modules\transfer.js
 * @Description: 移交
 */
import { useBaseInfoWithOut } from '@/store/modules/base-info';
import { submitReturn } from './return/helper';
import {fireEvent, getCollEventParams} from "@/handles/common/sdk";
import globalData from "@/plugins/data";
export async function transfer() {
  const useBaseInfo = useBaseInfoWithOut();
  let hook = await fireEvent('transfer', getCollEventParams(useBaseInfo.businessData, globalData));
  if (!hook) {
    return;
  }
  $.selectPeople({
    type: 'selectPeople',
    panels: 'Department,Outworker,JoinOrganization,transferFunc,BusinessDepartment',
    selectType: 'Member',
    minSize: 1,
    maxSize: 1,
    text: this.$i18n('common.default.selectPeople.value'),
    hiddenPostOfDepartment: true,
    hiddenRoleOfDepartment: true,
    memberWithDeptInfo: true,
    showFlowTypeRadio: false,
    showMe: false,
    accessFileSecretLevel: useBaseInfo.baseInfo.secretLevel.value,
    callback: ({ obj: [{ memberId }] }) => {
      console.log('移交的人', memberId);
      submitReturn.call(
        this,
        { label: $.i18n('permission.operation.Transfer'), handleOriginal: 'Transfer' },
        (params) => {
          params.collaborationDealParamData.transferMemberId = memberId;
        }
      ).then(()=>{
        useBaseInfo.setIsHideGlobalLoading();
      })
    }
  });
}

export default function () {
  return new Promise((resolve) => {
    transfer.call(this);
    resolve();
  });
}
